
// pages/my/my.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userinfo:[],
    hasUserInfo:'',
    num:0,
    step:0,
    head:''
  },
  start_certification:function(){
    wx.navigateTo({
      url: '../certification/certification',
    })
  },
  start_info: function () {
    wx.navigateTo({
      url: '../info/info',
    })
  },
  collect: function () {
    wx.navigateTo({
      url: '../collect/collect',
    })
  },
  start_vip: function () {
    var usid = wx.getStorageSync('usid');
    wx.navigateTo({
      url: '../membuy/membuy',
    })
  },
  start_setup:function(){
    wx.navigateTo({
      url: '../about/about',
    })
  },
  start_message:function(){
    var usid = wx.getStorageSync('usid');
    wx.navigateTo({
      url: '../message/message',
    })
  },
  start_apply:function(){
    wx.navigateTo({
      url: '../collect/collect?type=1',
    })
  },
  start_subscribe:function(){
    var usid = wx.getStorageSync('usid');
    wx.navigateTo({
      url: '../subscribe/subscribe',
    })
  },
  start_merchants:function(){
    var usid = wx.getStorageSync('usid');
    wx.navigateTo({
      url: '../merchants/merchants',
    })
  },
  start_credit:function(){
    var usid = wx.getStorageSync('usid');
    wx.navigateTo({
      url: '../credit/credit',
    })
  },
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: '自定义转发标题',
      path: '/page/user?id=123',
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  getUserInfo: function (e) {
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {  
    let a = wx.getStorageSync('step');
    if (a == 0) {
      this.setData({
        step:0
      })
    }else{
      this.setData({
        step: 1
      })
    }
    console.log(options);
    this.setData({
      userinfo: wx.getStorageSync('userinfo'),
      head: wx.getStorageSync('head'),
      step: wx.getStorageSync('step')
    })
    var uid = wx.getStorageSync("uid");
    if(uid==false){
      wx.navigateTo({
        url: '../index/index',
      })
    }
    wx.request({
      url: 'https://www.135k.com/addons/sd_humans/tp/index.php/users/userinfo',
      data: {
        uid: uid
      },
      method: "post",
      success: function (res) {
        wx.setStorageSync("usid", res.data[0].uid);       
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var uid=wx.getStorageSync("uid");
    if(uid==null){
      wx.navigateTo({
        url: '../index/index',
      })
    }
    var _this = this;
    wx.request({
      url: app.data.Url + 'apply/collect_get',
      data: {
        uid: uid
      },
      method: 'get',
      success: function (res) {
        console.log(res.data)
        _this.setData({
          num: res.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  shoucang:function(){
    wx.navigateTo({
      url: '../collect/collect',
    })
  }
})